import request from './request'
import type { Appointment } from '@/types'

export const getAppointments = (params?: any) => {
  return request({
    url: '/appointment/page',
    method: 'post',
    data: params
  })
}

export const getAppointment = (id: number) => {
  return request({
    url: `/appointment/${id}`,
    method: 'get'
  })
}

export const createAppointment = (data: Partial<Appointment>) => {
  return request({
    url: '/appointment',
    method: 'post',
    data
  })
}

export const updateAppointment = (data: Partial<Appointment>) => {
  return request({
    url: `/appointment/update`,
    method: 'post',
    data
  })
}

export const deleteAppointment = (id: number) => {
  return request({
    url: `/appointment/cancel`,
    method: 'post',
    data: { id }
  })
}